<template>
  <el-card style="margin: 50px 20px">
    <h1>等级历程</h1>
    <el-table style="margin-top: 20px" :data="workerLevelHistoryList" v-loading="loading">
      <el-table-column label="更新时间" prop="time"></el-table-column>
      <el-table-column label="获得等级">
        <template scope="{row}">
          {{ getWorkerLevel(row.workerLevel) }}
        </template>
      </el-table-column>
      <el-table-column label="指标对应工作时间" prop="duration"></el-table-column>
      <el-table-column label="提交报告数量" prop="reportNumber"></el-table-column>
      <el-table-column label="报告优秀率" prop="excellentRate"></el-table-column>
      <el-table-column label="任务失信率" prop="dishonestRate"></el-table-column>
    </el-table>
  </el-card>
</template>

<script>
import {WORKER_LEVEL_MIXIN} from "@/views/const/worker-level";
import {getUserLevelHistory} from "@/api/worker";
export default {
  name: "LevelHistory",
  mixins: [WORKER_LEVEL_MIXIN],
  data(){
    return {
      workerLevelHistoryList: [],
      loading: false
    }
  },
  mounted() {
    this.loadWorkerLevelHistory()
  },
  methods: {
    loadWorkerLevelHistory() {
      this.loading = true;
      getUserLevelHistory(sessionStorage.getItem('userid'))
      .then(res => {
        if(res.code === 200){
          this.workerLevelHistoryList = res.data;
        }else{
          throw new Error(res.msg);
        }
      })
      .catch(e => {
        this.$message.error(e.message);
      }).finally(() => {
        this.loading = false;
      })
    },

  }
}
</script>

<style scoped>

</style>
